
/*
    var 没有块作用域，但是有函数作用域
    let 有块作用域
    --xx(error) let只有局部作用范围，var具有全局作用范围
*/
console.log("hello".length);

console.log("hello".charAt(0));

console.log("hello, world".replace("hello", "nachr"));

console.log("hello, world".toUpperCase());

console.log(1===1);

var name = "nachr";

console.log(name);

let id = 1;

console.log(id);

name = "lucas";

console.log(name);

// 123会自动转换为"123"
console.log( 123 == "123");     //true

// === 类型不会转换
console.log( 123 === "123");    //false

if(name === "lucas"){
    console.log("==");
}else{
    console.log("not");
}

//let只有局部作用范围，var具有全局作用范围
for(var i = 1; i < 4; i++){
    
}
console.log(i);

switch(name){
    case "nachr":
        console.log("nachr");
        break;
    case "lucas":
        console.log("lucas");
        break;
    default:
        console.log("default");
}

let obj = new Object();

obj = {
    name: "nachr",
    age: 20,
    contact:{
        email: "nanche2021@163.com",
        phone: 180-9933-9099
    }
}

console.log(obj.contact.email);

var arr = new Array();
var arr2 = [];

arr[0] = "dog";
arr[1] = "cat";
arr[2] = "pig";
arr.pop();
arr.push("ele");
arr.unshift("lu");

console.log(arr);

let a = 1;
function add(){
    a += 1;
}
add();
console.log(a);